<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!--<script src="js/sha256.min.js"></script>-->
    <!--<script src="js/elliptic.min.js"></script>-->
    <!--<script src="js/jquery.js"></script>-->
</head>
<body>

</body>
<script>
let ids = {
	"icgQf7G19ZMq97RUbsz3S6Y5sYiCT3qcEb": {
		"id": "icgQf7G19ZMq97RUbsz3S6Y5sYiCT3qcEb",
		"kyc": {
			"person": {
				"order": {
					"VTT1530900147221199": {
						"txHash": "375cfb778c9fb114dc098eb15d37d7488bb5ed578813db0c517850af672a1e91",
						"serialNum": "VTT1530900147221199"
					}
				}
			},
			"company": {
				"order": {
					"RLU1530971869338288": {
						"txHash": "510e0d8cb4195f6d5050a0ca87948bd91eee05f95d7e9143278d8e7909bd7f81",
						"serialNum": "RLU1530971869338288",
						"status": 1,
						"params": {
							"id": "icgQf7G19ZMq97RUbsz3S6Y5sYiCT3qcEb",
							"appName": "kyc",
							"type": "company",
							"adata": [{
								"type": "enterprise",
								"result": "success",
								"retdata": {
									"app": "b1c0b7028c8c4be3beafc4c4812ae92e",
									"signature": "a46616afee601bfd26651dba4afe33c54e865f6a8b504bb3dd042edde934669affcfa77e4b3798d9539c4131c1af545bba6e65987a71e6abefe195ca0435e8af",
									"RegistrationNum": "911101080804655794",
									"legalPerson": "詹克团",
									"word": "北京比特大陆科技有限公司",
									"authid": "12345678",
									"ts": "1532506548"
								},
								"message": "认证成功",
								"timestamp": "1532506561601",
								"resultSign": "3045022079b6cab8d7d91ae76813f7da0e725c903288ed5b51cb931591eb23ea2827cc9e022100eb393cadf921c73c0a4fa00317683058250d256f77e771675ffb6120f5ea4cbe"
							}]
						}
					},
					"TIN1531045028308086": {
						"txHash": "66cb274d4b50e56293e0de42d982ce808909ba471edb601635193dcbaf840efc",
						"serialNum": "TIN1531045028308086",
						"status": 1,
						"params": {
							"id": "icgQf7G19ZMq97RUbsz3S6Y5sYiCT3qcEb",
							"appName": "kyc",
							"type": "company",
							"adata": [{
								"type": "enterprise",
								"result": "success",
								"retdata": {
									"app": "b1c0b7028c8c4be3beafc4c4812ae92e",
									"signature": "e75d4431d75f2b9ff344980effbc0c0eb9cbacd2628f9ad3151508c30e635c20b051a32b4931bc11cfbf8151208121608f5cffb3c0a870ccd638bc0d9bf19ecc",
									"RegistrationNum": "911101080804655794",
									"legalPerson": "詹克团",
									"word": "北京比特大陆科技有限公司",
									"authid": "12345678",
									"ts": "1532578077"
								},
								"message": "认证成功",
								"timestamp": "1532675774538",
								"resultSign": "3046022100cb7c0dca27d97c2a04c11c1161be5321cbc18ce2ef26bf5f796e55fc973ceaef0221009ced944e53d8ecaa71aac8dcc65ca87dcb464f6415fb9f52a2f48d5d869e28c9"
							}]
						}
					}
				}
			}
		}
	},
	"icLDfCPLE4ukMT98uc6RLBRMbU7kEVS7Jw": {
		"id": "icLDfCPLE4ukMT98uc6RLBRMbU7kEVS7Jw",
		"kyc": {
			"person": {
				"order": {
					"VMN1530988285253940": {
						"txHash": "c71a83a5aa50513bffe507d819d0d7657d78c752a73ae7ce41b081d687f2ea83",
						"serialNum": "VMN1530988285253940"
					},
					"WIY1531042401043980": {
						"txHash": "88a3dc5afa44b933118a05b87e9ddd9a9e47c8259dd644bbfd7c28cf4401b5c6",
						"serialNum": "WIY1531042401043980",
						"status": 1,
						"params": {
							"id": "icLDfCPLE4ukMT98uc6RLBRMbU7kEVS7Jw",
							"appName": "kyc",
							"type": "person",
							"adata": [{
								"type": "identityCard",
								"result": "fail",
								"retdata": {
									"app": "b1c0b7028c8c4be3beafc4c4812ae92e",
									"identityNumber": "410426198811151012",
									"signature": "ad9df962257ff74095e2ef57d193d76863a287af9ca63735a94eaad860b310e4e3863bb6779711d7d44d3031d9b77cf6f6ff09a36d337ac437ab50ce80a8c5fd",
									"fullName": "sss",
									"authid": "12345678",
									"ts": "1532575197"
								},
								"message": "认证失败",
								"timestamp": "1532575217651",
								"resultSign": "30440220686636a8c7b524f8ebdd97c2a8689f2389554da5e380f1490410c2d80ee141dc022024493c6ac9fb103401cb0ef7f40b6e82a4c4f5f85ea7d7c254b51b409235ecf3"
							}]
						}
					}
				}
			}
		}
	},
	"iewY47FYSPkEBCRFSzKFfXG1KksiZThy16": {
		"id": "iewY47FYSPkEBCRFSzKFfXG1KksiZThy16",
		"kyc": {
			"person": {
				"order": {
					"HVL1531050647361408": {
						"txHash": "534502cc52e8b49d6f81d6a1cd69f3cceea4708fee34a974335f8b826f080493",
						"serialNum": "HVL1531050647361408",
						"status": 1,
						"params": {
							"id": "iewY47FYSPkEBCRFSzKFfXG1KksiZThy16",
							"appName": "kyc",
							"type": "person",
							"adata": [{
								"type": "identityCard",
								"result": "success",
								"retdata": {
									"app": "b1c0b7028c8c4be3beafc4c4812ae92e",
									"identityNumber": "410426198811151012",
									"signature": "2a19abed07b36348f8d60d4f56dc98d249df1e7e2ee63579f908d69d5fca1dc7ca18781ab842673de20a56ab22786c3450614acca942604f24ec6ea0b5b76b3f",
									"fullName": "宋家准",
									"authid": "12345678",
									"ts": "1532583359"
								},
								"message": "认证成功",
								"timestamp": "1532583582624",
								"resultSign": "3044022060f94a0468476128137419cdbce4119447c5a1ab2c3726ea425b52b53260307102204da37c14ba89d2cdcb048c4e6012d0c68fa6c44efb95b11c26d53d368ad6234c"
							}]
						}
					},
					"EEZ1531051833346236": {
						"txHash": "fc9ada7d5d009262409bff5e77a899fdc30288de7250e54f56cf90a4d41b6947",
						"serialNum": "EEZ1531051833346236",
						"status": 1,
						"params": {
							"id": "iewY47FYSPkEBCRFSzKFfXG1KksiZThy16",
							"appName": "kyc",
							"type": "person",
							"adata": [{
								"type": "identityCard",
								"result": "success",
								"retdata": {
									"app": "b1c0b7028c8c4be3beafc4c4812ae92e",
									"identityNumber": "410426198811151012",
									"signature": "da12d5d3b15c42ab7cada88810ec578d6745b91e28cf33dfb2a215a60f69fa79ec3116faf47d36e43fd94100b1a80d2e85ea4af52bd483048b327e40b7c5c699",
									"fullName": "宋家准",
									"authid": "12345678",
									"ts": "1532584799"
								},
								"message": "认证成功",
								"timestamp": "1532584858522",
								"resultSign": "3045022100b800312fb4d824c4699cf4ff20837e29722e22f50535da6815336de2a9b6605b02204aef5f2476bf12482d4b73568614e3426eb261a8a27b5f171fed928759bae847"
							}, {
								"type": "phone",
								"result": "success",
								"retdata": {
									"app": "b1c0b7028c8c4be3beafc4c4812ae92e",
									"identityNumber": "410426198811151012",
									"signature": "428dd9fab4c63a1301609177fc165abc18f3f798ab93b388d7c5c9e89911d249d93bf37122383c47fdd8bdc477a6257d7d7962260dc73471613b2bf6ba8cb694",
									"mobile": "18210230496",
									"fullName": "宋家准",
									"authid": "12345678",
									"ts": "1532584799"
								},
								"message": "认证成功",
								"timestamp": "1532584858522",
								"resultSign": "3045022100e5ac2c6bbb5c5042c51cc18696d1f37e20f5f5591f7085fdc3efabad0bc8016b02206f8de35b0a783917e8489a8038cb820c6f08d3d7cd095f26611afb9d0238d79c"
							}]
						}
					},
					"TNL1531052347373694": {
						"txHash": "196a23ec728a8b984fc8adf8f108ec1bf534cdbd032cebc48d8bc3c77a2a3b27",
						"serialNum": "TNL1531052347373694",
						"status": 1,
						"params": {
							"id": "iewY47FYSPkEBCRFSzKFfXG1KksiZThy16",
							"appName": "kyc",
							"type": "person",
							"adata": [{
								"type": "identityCard",
								"result": "success",
								"retdata": {
									"app": "b1c0b7028c8c4be3beafc4c4812ae92e",
									"identityNumber": "410426198811151012",
									"signature": "3adb5ef3593541dfcc3af21063227833d48ae50224ff479004748325715d2b942532364e463c3a81a04d05db6a2f8dc40cd521d75eae162a36fec5c2b5a64803",
									"fullName": "宋家准",
									"authid": "12345678",
									"ts": "1532585280"
								},
								"message": "认证成功",
								"timestamp": "1532585373718",
								"resultSign": "30460221008d677c0917270b7ed8996a472d905c499e62f79c841468a0c90e34ff9c0fb40e022100a8a6c43eaa48425b27a8c5789a50951db4dc21f744a14607ceb7c7e6b9cd5207"
							}, {
								"type": "bankCard",
								"result": "fail",
								"retdata": null,
								"message": "无信息",
								"timestamp": "1532585373718",
								"resultSign": "3046022100b557796782b3392adfc51b9acacc93857cf8dd3ee206bc35613a445809cfd009022100c1f29f71dfbd60a7a36c1d55228f45f4a4bc1bb24fd4889c79aa83548ae9cefe"
							}]
						}
					},
					"WSE1531054511779122": {
						"txHash": "11de788a37cd2b8777fca7ed313232681257fe2f380d93c392d6d02f47171e8c",
						"serialNum": "WSE1531054511779122",
						"status": 1,
						"params": {
							"id": "iewY47FYSPkEBCRFSzKFfXG1KksiZThy16",
							"appName": "kyc",
							"type": "person",
							"adata": [{
								"type": "identityCard",
								"result": "success",
								"retdata": {
									"app": "b1c0b7028c8c4be3beafc4c4812ae92e",
									"identityNumber": "410426198811151012",
									"signature": "9f84e0c9546ef01ea0c6c077d60a7d3a9486847a9fad71562890081fd467a02a257950ee563a1298f7f0e6907c88b64c9a50c7d939fb36971751e59fd33e019f",
									"fullName": "宋家准",
									"authid": "12345678",
									"ts": "1532587201"
								},
								"message": "认证成功",
								"timestamp": "1532587852623",
								"resultSign": "3045022100aa8addd6408c7389f25e91c21af06e29b23760ac8869980345a51065e00a8fee02205de4240b25ea0837c08b9b9988ef3488fd22937571857959fa887fa0ef9dfa0e"
							}, {
								"type": "bankCard",
								"result": "fail",
								"retdata": null,
								"message": "无信息",
								"timestamp": "1532587852623",
								"resultSign": "30440220590221ac2379a412c0086e77e11b3eba0a9a90b0130b21d37d691b55d1c6a98b022017a08d4f68a74894ed6e15e6039350023cba88f5754a47982fd782f1e89b8dec"
							}]
						}
					},
					"GEB1531056345447618": {
						"txHash": "aee4106d49b1d1507c7130bb9bb2d9b30a27bbde9ec98414bf2e9e1eed1fd8b7",
						"serialNum": "GEB1531056345447618",
						"status": 1,
						"params": {
							"id": "iewY47FYSPkEBCRFSzKFfXG1KksiZThy16",
							"appName": "kyc",
							"type": "person",
							"adata": [{
								"type": "identityCard",
								"result": "success",
								"retdata": {
									"app": "b1c0b7028c8c4be3beafc4c4812ae92e",
									"identityNumber": "410426198811151012",
									"signature": "194415ea346b60e5af512302507a156718e28f9fdb016f38b7f84abbd6a55c98e2e643e22e25ae52aa6622af31f8b79f50399283bcc99dd05f786a31b81bb266",
									"fullName": "宋家准",
									"authid": "12345678",
									"ts": "1532589122"
								},
								"message": "认证成功",
								"timestamp": "1532595140256",
								"resultSign": "3046022100df445e63268d25b34ae89328cb6973e18180c754da7578d5f4920089583108790221008d6053a1ebffdcd0373ca878fdc30702291d1e5c343e4c41c699d455e7f129c9"
							}, {
								"type": "bankCard",
								"result": "fail",
								"retdata": null,
								"message": "无信息",
								"timestamp": "1532595140256",
								"resultSign": "3046022100b1307d7ec56120474d6169b09e293fe404bd03754e232ba9254e275598b7f6d2022100ca83de0a166da154d4d8006058989fad3f5e75fe4a1fb70b49d0d28a0e576cf4"
							}]
						}
					}
				}
			},
			"company": {}
		}
	},
	"ioEF4VCSu2whqm9hD44jhkjCMAqd4U8Q3k": {
		"id": "ioEF4VCSu2whqm9hD44jhkjCMAqd4U8Q3k",
		"kyc": {
			"person": {
				"order": {
					"OJR1531062568715121": {
						"txHash": "6677894d0a3ba5f708bcd66905ed3f79c90ac85f6aced30d3789f1a3da85e63f",
						"serialNum": "OJR1531062568715121",
						"status": 1,
						"params": {
							"id": "ioEF4VCSu2whqm9hD44jhkjCMAqd4U8Q3k",
							"appName": "kyc",
							"type": "person",
							"adata": [{
								"type": "identityCard",
								"result": "success",
								"retdata": {
									"app": "b1c0b7028c8c4be3beafc4c4812ae92e",
									"identityNumber": "410426198811151012",
									"signature": "f17637255a37408066abdc7833dc19e29839c823b0af2e91cc3129d4c11ae675550e13aca9ddc1cbd560f2f883fc418ebc88039a44bff4f672ba723f56f5216c",
									"fullName": "宋家准",
									"authid": "12345678",
									"ts": "1532595632"
								},
								"message": "认证成功",
								"timestamp": "1532595748881",
								"resultSign": "30440220577a2d8ff8a1d99f2386cd8be6a32220c9919d89d42d65475cd9453c184fd7ec0220320926e8bb1ea03c94ef21210937cca46a8cd6922e715b76d14930fd6189e4fd"
							}, {
								"type": "bankCard",
								"result": "success",
								"retdata": {
									"app": "b1c0b7028c8c4be3beafc4c4812ae92e",
									"identityNumber": "410426198811151012",
									"signature": "68103c27bc83271136adeaa02731c26d246bda60afff83c22e26c328e32d6815f00c43d784f22911111bca523584e0583138c311c3aea04c58e005846fe18cfa",
									"mobile": "18210230496",
									"fullName": "宋家准",
									"cardNumber": "6225880167820399",
									"authid": "12345678",
									"ts": "1532595632"
								},
								"message": "认证成功",
								"timestamp": "1532595748881",
								"resultSign": "30440220414d48834d32f7ea22f8fd3afd469ad23d0a6b84b87f0630b95337f31b2a563b02205363e760cf9895464b230a58cd4827cf47082bc426b39a8c7b131866c6da2e40"
							}]
						}
					}
				}
			}
		}
	},
	"iZzgcVwu5uoca7NT4VpTV3fuYM1jHmgz52": {
		"id": "iZzgcVwu5uoca7NT4VpTV3fuYM1jHmgz52"
	}
}



function getSertoId(){

let target = {};
let newIds = {};

for(let id in ids){

  let  idJsonObj = ids[id];

  if (! idJsonObj["kyc"]){
      continue;
  }
  for (let authType in idJsonObj["kyc"]){
      if (!idJsonObj["kyc"][authType]["order"]){
        continue
      }
      let order = idJsonObj["kyc"][authType]["order"];

      for (let prop in order) {

        if ( order[prop]["params"] && order[prop]["params"]["adata"])
        {
          var addataArry = [];
          addataArry = order[prop]["params"]["adata"];

          addataArry.forEach(function (value) {

            if (value && value["retdata"]) {

              if ( value["retdata"]["signature"]) {
                let sign = value["retdata"]["signature"];
                target[sign] = order[prop];
                console.info( "ElastosJs add sign " + sign + " obj "+ JSON.stringify(order[prop]));
              }
            }
          })
        }

      }
  }

}

  return target;
}

function add(idObj,newIds,id,appName,appr){
      if(idObj[appName][appr]){
        if(idObj[appName][appr]["order"]){
           for(let index in idObj[appName][appr]["order"]){
               newIds[index] ={"id":id,"appName":appName,"appr":appr};
           }
        }
    }
}

let ss = getSertoId();

console.log("============"+JSON.stringify(ss));
alert("====kyc===="+JSON.stringify(ss));

</script>
</html>
